package com.huoniu.commons.utils;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

@AllArgsConstructor
@Data
public class ResultEntity implements Serializable {

    public boolean status;

    public int resCode;

    public String resMsg;

    public Object data;

    public ResultEntity() {
        this.resCode = ResultCode.SUCCESS.getResCode();
        this.resMsg = ResultCode.SUCCESS.getResMsg();
        this.status = true;
    }

    public ResultEntity(ResultCode resultCode, boolean status) {
        this.resCode = resultCode.getResCode();
        this.resMsg = resultCode.getResMsg();
        this.status = status;
    }

    public boolean isStatus() {
        return status;
    }

}

enum ResultCode {


    SUCCESS(1, "请求成功!"), FAILED(0, "操作失败,请重试!");

    private Integer resCode;
    private String resMsg;

    ResultCode(Integer resCode, String resMsg) {
        this.resCode = resCode;
        this.resMsg = resMsg;
    }

    public Integer getResCode() {
        return resCode;
    }

    public String getResMsg() {
        return resMsg;
    }
}